﻿<%@ Control Language="C#" AutoEventWireup="true" Inherits="HL.Lib.MVC.CPViewControl" %>
<script runat="server">
   
    private List<EntityBase> AutoGetMap(ModPropertyModel model)
    {
        List<EntityBase> list = new List<EntityBase>();

        int _id = model.ParentID;
        while (_id > 0)
        {
            ModPropertyEntity _Menu = ModPropertyService.Instance.GetByID(_id);

            if (_Menu == null)
                break;

            _id = _Menu.ParentID;

            list.Insert(0, _Menu);
        }

        return list;
    }
</script>
<%
    var model = ViewBag.Model as ModPropertyModel;
    var listEntity = ViewBag.Data as List<ModPropertyEntity>;
    var parent = ModPropertyService.Instance.GetByID(model.ParentID);
%>
<form id="hlForm" name="hlForm" method="post">
<input type="hidden" id="_hl_action" name="_hl_action" />
<input type="hidden" id="boxchecked" name="boxchecked" value="0" />
<div id="toolbar-box">
    <div class="t">
        <div class="t">
            <div class="t">
            </div>
        </div>
    </div>
    <div class="m">
        <div class="toolbar-list" id="toolbar">
            <%--            <%if (parent != null && parent.ParentID != 0)
              { %>
            <%=GetListCommand("new|Thêm,edit|Sửa,space,publish|Duyệt,unpublish|Bỏ duyệt,space,search|Tìm kiếm,unsearch|Bỏ Tìm kiếm,space,delete|Xóa,copy|Sao chép,space,config|Xóa cache")%>
            <%}
              else
              { %>
            <%=GetDefaultListCommand()%>
            <%} %>--%>
            <%=GetListCommand("new|Thêm,edit|Sửa,space,publish|Duyệt,unpublish|Bỏ duyệt,space,delete|Xóa,copy|Sao chép,space,config|Xóa cache")%>
        </div>
        <div class="pagetitle icon-48-generic">
            <h2>
                Thuộc tính sản phẩm</h2>
        </div>
        <div class="clr">
        </div>
    </div>
    <div class="b">
        <div class="b">
            <div class="b">
            </div>
        </div>
    </div>
</div>
<div class="clr">
</div>
<script type="text/javascript">

    var HLController = 'ModProperty';

    var HLArrVar = [
                        'limit', 'PageSize'
                   ];


    var HLArrVar_QS = [
                        'filter_search', 'SearchText'
                      ];

    var HLArrQT = [
                      '<%= model.PageIndex + 1 %>', 'PageIndex',
                      '<%= model.ParentID %>', 'ParentID',
                      '<%= model.Sort %>', 'Sort'
                  ];

    var HLArrDefault =
                  [
                    '1', 'PageIndex',
                    '20', 'PageSize'
                  ];
</script>
<%= ShowMessage()%>
<div id="element-box">
    <div class="t">
        <div class="t">
            <div class="t">
            </div>
        </div>
    </div>
    <div class="m">
        <%--        <table>
            <tr>
                <td width="100%">
                    Lọc:
                    <input type="text" id="filter_search" value="<%= model.SearchText %>" class="text_area"
                        onchange="HLRedirect();return false;" />
                    <button onclick="HLRedirect();return false;">
                        Tìm kiếm</button>
                </td>
                <td nowrap="nowrap">
                </td>
            </tr>
        </table>--%>
        <table>
            <tr>
                <td width="100%">
                    <%= ShowMap(AutoGetMap(model))%>
                </td>
            </tr>
        </table>
        <table class="adminlist" cellspacing="1">
            <thead>
                <tr>
                    <th width="1%">
                        #
                    </th>
                    <th width="1%">
                        <input type="checkbox" name="toggle" value="" onclick="checkAll(<%= model.PageSize %>);" />
                    </th>
                    <th width="1%">
                        #
                    </th>
                    <th class="title">
                        <%= GetSortLink("Tên", "Name")%>
                    </th>
<%--                    <%if (parent != null && parent.ParentID != 0)
                      { %>
                    <th class="title" width="15%">
                        <%= GetSortLink("Là tiêu chí tìm kiếm", "Search")%>
                    </th>
                    <%} %>--%>
<%--                                        <th class="title" width="15%">
                        <%= GetSortLink("Là tiêu chí tìm kiếm", "Search")%>
                    </th>--%>
                    <th width="1%" nowrap="nowrap">
                        <%= GetSortLink("Thứ tự", "Order")%>
                        <a href="javascript:hl_exec_cmd('saveorder')" class="saveorder" title="Lưu sắp xếp">
                        </a>
                    </th>
                    <th width="1%" nowrap="nowrap">
                        <%= GetSortLink("ID", "ID")%>
                    </th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <td colspan="15">
                        <del class="container">
                            <%= GetPagination(model.PageIndex, model.PageSize, model.TotalRecord)%>
                        </del>
                    </td>
                </tr>
            </tfoot>
            <tbody>
                <%for (int i = 0; listEntity != null && i < listEntity.Count; i++)
                  { %>
                <tr class="row<%= i%2 %>">
                    <td align="center">
                        <%= i + 1%>
                    </td>
                    <td align="center">
                        <%= GetCheckbox(listEntity[i].ID, i)%>
                    </td>
                    <td align="center">
                        <a href="javascript:HLRedirect('Add', <%= listEntity[i].ID %>)">
                            <img src="/{CPPath}/Content/add/img/edit_f2.png" width="15px" />
                        </a>
                    </td>
                    <td>
                        <a href="javascript:HLRedirect('Index', <%= listEntity[i].ID %>, 'ParentID')">
                            <%= listEntity[i].Name%></a>
                    </td>
<%--                    <%if (parent != null && parent.ParentID != 0)
                      { %>
                    <td class="order">
                        <div style="text-align: center;">
                            <%= listEntity[i].Search ? "Có" : "Không"%></div>
                    </td>
                    <%} %>
                                        <td class="order">
                        <div style="text-align: center;">
                            <%= listEntity[i].Search ? "Có" : "Không"%></div>
                    </td>--%>
                    <td class="order">
                        <%= GetOrder(listEntity[i].ID, listEntity[i].Order)%>
                    </td>
                    <td align="center">
                        <%= listEntity[i].ID%>
                    </td>
                </tr>
                <%} %>
            </tbody>
        </table>
        <div class="clr">
        </div>
    </div>
    <div class="b">
        <div class="b">
            <div class="b">
            </div>
        </div>
    </div>
</div>
</form>
